Skip to content

test(gateway): end-to-end coverage for both auth-enabled and no-auth flows - #188

Merged
its-mash merged 2 commits into
mainfrom
test/no-auth-coverage
Jun 25, 2026
Merged

test(gateway): end-to-end coverage for both auth-enabled and no-auth flows#188
its-mash merged 2 commits into
mainfrom
test/no-auth-coverage

Conversation

@its-mash

@its-mash its-mash commented Jun 25, 2026

Copy link
Copy Markdown
Member

Comprehensive E2E coverage for inbound auth, prompted by real reports while toggling auth (no-auth "stuck at initialize", and "is the enabled flow still intact?"). No production behavior change — these are tests plus exposing existing handlers for tests.

Auth DISABLED (no-auth)

  • authless_anonymous_client_completes_real_initialize — boots the real gateway with the real mcp_oauth_middleware + auth disabled, drives it with a real rmcp client that sends no token, and proves the anonymous handshake completes end to end (initialize + list_tools).
  • Discovery endpoints 404 when disabled / 200 when required — including the RFC 9728 /.well-known/oauth-protected-resource/mcp sub-path that editors (VS Code) probe first (its stale 200 was what pushed clients into an OAuth flow against an authless gateway).

Auth ENABLED (full OAuth)

  • auth_enabled_full_oauth_flow_then_authenticated_mcp — drives the real production handlers over HTTP against a gateway with auth required + JWT secret:
    DCR register → authorize (consent page) → consent approve (redirect + code) → token exchange (PKCE S256) → authenticated /mcp handshake 200, and a tokenless /mcp401.
    This guarantees the "disable auth" feature can't silently regress real OAuth.

To mount the flow self-contained, the OAuth handlers (oauth_register/authorize/token/consent_approve) are now pub use-exported from the server module — the same pattern already used for the discovery handlers.

All 24 streamable_http tests pass locally.

https://claude.ai/code/session_01Baan9JmzR43uxxRUh7CAMF

its-mash added 2 commits June 25, 2026 13:39
The earlier no-auth tests stubbed the `/mcp` handler and only checked two
discovery endpoints — so they couldn't catch the real failure an editor hit:
with auth disabled but discovery still advertising OAuth (the pre-#187 state),
VS Code probed `/.well-known/oauth-protected-resource/mcp`, got 200, entered an
OAuth flow, and stalled at `initialize`.

- auth_disable: assert the RFC 9728 `/.well-known/oauth-protected-resource/mcp`
  sub-path (the one editors probe first) 404s when auth is disabled and is
  served when required, alongside the other two endpoints.
- gateway_notifications: add `authless_anonymous_client_completes_real_initialize`
  — boots the real gateway with the REAL `mcp_oauth_middleware` + auth disabled
  and drives it with a real rmcp client that sends no token, proving the
  anonymous handshake completes end to end (initialize + list_tools) rather than
  hanging.

Claude-Session: https://claude.ai/code/session_01Baan9JmzR43uxxRUh7CAMF
Signed-off-by: Mohammod Al Amin Ashik <maa.ashik00@gmail.com>
Adds a real end-to-end test of the AUTH-REQUIRED path so we can guarantee the
"disable auth" feature never silently regresses real OAuth. It drives the
actual production handlers over HTTP against a gateway with inbound auth
required + a JWT secret configured:

  DCR register → authorize (consent page, request_id) → consent approve
  (redirect with code) → token exchange (PKCE S256) → authenticated /mcp
  handshake returns 200; the same handshake with no token returns 401.

To mount the flow in a self-contained harness, expose the OAuth handlers
(oauth_register/authorize/token/consent_approve) from the server module, the
same way the discovery handlers were already exposed for tests.

Together with the disabled-side coverage (anonymous real handshake + list_tools,
discovery 404 incl. the RFC 9728 /mcp sub-path), both auth modes are now proven
end to end.

Claude-Session: https://claude.ai/code/session_01Baan9JmzR43uxxRUh7CAMF
Signed-off-by: Mohammod Al Amin Ashik <maa.ashik00@gmail.com>
@its-mash its-mash changed the title test(gateway): cover the no-auth handshake + RFC 9728 sub-path discovery test(gateway): end-to-end coverage for both auth-enabled and no-auth flows Jun 25, 2026
@its-mash
its-mash merged commit db1596f into main Jun 25, 2026
13 checks passed
@its-mash
its-mash deleted the test/no-auth-coverage branch June 25, 2026 07:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant